home *** CD-ROM | disk | FTP | other *** search
- #include <setjmp.h>
- #include "extras.h"
-
- static int hold_rv;
-
- int catch(context, func)
- jmp_buf context;
- int (*func) __PROTO((void));
- {
- if (setjmp(context) == 0) {
- return (*func)();
- } else {
- return hold_rv;
- }
- }
-
- void throw(context, rv)
- jmp_buf context;
- int rv;
- {
- hold_rv = rv;
- longjmp(context, 1);
- }
-